package com.example.tys.baseapplication.util;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by tys on 2017/9/25.
 */

public class SharedPreferencesUtil {
    private static final String SHARED_PREFERENCES_NAME = "Setting";

    public static String getString(Context context, String name) {
        SharedPreferences sp = getSharedPreferences(context);
        return sp.getString(name, "");
    }

    public static void putString(Context context, String name, String val) {
        SharedPreferences sp = getSharedPreferences(context);
        sp.edit().putString(name, val).apply();
    }




    private static SharedPreferences getSharedPreferences(Context context) {
        return context.getSharedPreferences(
                SharedPreferencesUtil.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    }
}
